<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>简途旅行</title>
    <meta name="format-detection" content="telephone=no"/>
    <meta name="wap-font-scale" content="no">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <link rel="stylesheet" href="/old/css/lottery/lottery.scss?__inline" media="screen" title="no_title" charset="utf-8">
</head>
<body style="visibility: hidden;">
<div class="wrap">
    <div class="container">
        <div class="header">
            <img src="https://images.simpletour.com/activity/lottery/lottery_headerBg.png" alt=""/>
        </div>
        <div class="content">
            <div class="title-wrap">
                <div class="title">
                    <img src="https://images.simpletour.com/activity/lottery/lottery_title.png" alt=""/>
                </div>
                <div class="time">活动时间:2017.03.28-2017.04.05</div>
            </div>
            <div class="input-wrap">
                <span><input type="text" name="mobile" placeholder="输入您的手机号码再点击摇奖"/></span>
                <span id="start" class="start loading">摇奖<label></label></span>
            </div>
            <div class="turntable-wrap">
                <div class="turntable">
                    <img class="wheel thanks" src="https://images.simpletour.com/activity/lottery/turntable.png"
                         alt=""/>
                    <img class="point" src="https://images.simpletour.com/activity/lottery/point.png"/>
                </div>
            </div>
            <a class="toUse"><img src="https://images.simpletour.com/activity/lottery/toUse.png" alt=""/></a>
            <div class="btns">
                <a class="btn">中奖纪录</a>
                <a class="btn">活动规则</a>
            </div>
            <a class="action">春蠢欲动,不如行动</a>
        </div>
    </div>
</div>
<script type="text/javascript" src="/js/zepto.min.5551012.js"></script>
<script type="text/javascript" src="/js/base.js"></script>
<script>
    (function (doc, win) {
        var docEl = doc.documentElement,
                resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
                recalc = function () {
                    var clientWidth = docEl.clientWidth;
                    if (!clientWidth) return;
                    // 针对uc横竖屏rem html没有重绘的问题
                    var style;
                    if (style = document.getElementById("forhtml")) {
                        style.parentNode.removeChild(style);
                    }
                    style = document.createElement("style");
                    style.id = "forhtml";
                    document.head.appendChild(style);
                    style.appendChild(document.createTextNode("html{font-size:" + 20 * (clientWidth / 320) + "px !important;}"));
                };
        recalc();
        document.body.style.visibility = 'visible';
        if (!doc.addEventListener) return;
        win.addEventListener(resizeEvt, recalc, false);
        doc.addEventListener('DOMContentLoaded', recalc, false);
        var a = document.getElementsByTagName('a');
        for (var i = 0; i < a.length; i++) {
            a[i].addEventListener('touchstart', function () {
            }, false);
        }
        document.body.addEventListener('touchstart', function () {
        });
    })(document, window);
    $(document).ready(function () {
        var platform = 'wechat';

        function stop($wheel, deg) {
            setTimeout(function () {
                $wheel.css({
                    '-webkit-transition': '3s ease-in-out',
                    'transition': '3s ease-in-out',
                    '-webkit-transform': 'rotate(' + deg + 'deg)',
                    'transform': 'rotate(' + deg + 'deg)'
                });
            }, 2);
        }

        $('#start').click(function (e) {
            e.preventDefault();
            var $this = $(this);
            if (!$this.hasClass('disabled')) {
                var mobile = $.trim($('input[name=mobile]').val());
                if (!mobile) {
                    $.alert({
                        msg: '请输入您的手机号码'
                    });
                } else if (!/^0?(13|14|15|17|18)[0-9]{9}$/.test(mobile) && !/^(0)[0-9]{9}$/.test(mobile)) {
                    $.alert({
                        msg: '请输入正确的手机号码'
                    });
                } else {
                    $this.addClass('disabled');
                    var array = [195, 50, 267, 337, 125], $wheel = $('img.wheel'), index = 4;
                    $.ajax({
                        url: '/mobile/gateway/wechat/activity/thailand/lottery',
                        type: 'post',
                        dataType: 'json',
                        data: {mobile: mobile},
                        success: function (data) {
                            if (data.code == 0) {
                                if (data.data.group) {
                                    $wheel.addClass('rotates');
                                    setTimeout(function () {
                                        index = parseInt(data.data.group);
                                        stop($wheel, array[index - 1]);
                                        if (index == 1 || index == 2) {
                                            var html = '<p>' + resData.data.alertMsg + '</p>';
                                            if (platform == 'wechat') {
                                                html += '<a class="jump" href="https://m.simpletour.com/mobile/gateway/wechat/home/home/">去使用优惠券</a>';
                                            } else {
                                                html += '<a class="jump" href="https://m.simpletour.com/mobile/gateway/app/act/page/176">去使用优惠券</a>';
                                            }
                                            $.confirm({
                                                title: '領取成功',
                                                detail: [html],
                                                yes: '确定',
                                            });
                                        } else {
                                            $.confirm({
                                                title: '領取成功',
                                                detail: [data.data.alertMsg],
                                                yes: '确定',
                                            });
                                        }
                                    }, 3000);
                                } else {
                                    $.confirm({
                                        title: '領取成功',
                                        detail: [data.data.alertMsg],
                                        yes: '确定',
                                    });
                                }
                            } else {
                                $.alert({
                                    msg: data.reason
                                });
                            }
                        },
                        error: function () {
                            $.alert({
                                msg: '网络异常，请重试！'
                            });
                        }
                    });
                }
            }
        });
    });
</script>
</body>
</html>